package com.cskaoyan.dbutils.queryrunner;

import com.cskaoyan.connectionpool.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

public class QueryRunnerDemo2 {

    public static void main(String[] args) throws SQLException {


        DataSource dataSource = DruidUtils.getDataSource();

        QueryRunner queryRunner = new QueryRunner(dataSource);

        // QueryRunner有两个构造方法，
        // 1. 无参构造
        // 2. 传入一个数据库连接池来构造

        int affectedRows = queryRunner.update("update account set money = ? where name = ?", 20000, "长风");

        System.out.println("affectedRows:" + affectedRows);


    }
}
